# data_air_c.py

import json
import random

locations = ["BJ", "TJ", "SH", "NJ", "WH", "ZZ", "CS", "XM", "GZ", "SZ"]
time_ranges = [1, 2, 3]

def generate_amount(min_amount=100, max_amount=200):
    return round(random.uniform(min_amount, max_amount))

def generate_available():
    return random.choice([0, 1])

def mock_api_response(start=None, end=None, time_range=None):
    if not start:
        start = random.choice(locations)
    if not end or end == start:
        end = random.choice([loc for loc in locations if loc != start])
    if not time_range:
        time_range = random.choice(time_ranges)

    available = generate_available()
    price = generate_amount(100, 1500) if available == 1 else None

    return {
        "start": start,
        "end": end,
        "time": time_range,
        "available": available,
        "price": price,
    }

def generate_multiple_data(count=100):
    return [mock_api_response() for _ in range(count)]

def save_data_to_json(data, filename="generated_data.json"):
    with open(filename, "w", encoding="utf-8") as f:
        json.dump(data, f, indent=2, ensure_ascii=False)
    print(f"数据已保存至 {filename}")

# 如果直接运行此文件，则生成并保存100条数据
if __name__ == "__main__":
    all_data = generate_multiple_data(10000)
    save_data_to_json(all_data)
